package RedisDay3;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.List;

public class RedisClusterDemo1 {
    public static void main(String[] args) {
        HashSet<HostAndPort> hostAndPorts = new HashSet<>();
        hostAndPorts.add(new HostAndPort("192.168.111.166",7000));
        hostAndPorts.add(new HostAndPort("192.168.111.166",7001));
        hostAndPorts.add(new HostAndPort("192.168.111.166",7002));
        hostAndPorts.add(new HostAndPort("192.168.111.166",7003));
        hostAndPorts.add(new HostAndPort("192.168.111.166",7004));
        hostAndPorts.add(new HostAndPort("192.168.111.166",7005));
        JedisCluster jedisCluster = new JedisCluster(hostAndPorts);
//        System.out.println(jedisCluster.get("name"));
//        jedisCluster.lpush("score","88","99","100");
//        List<String> score = jedisCluster.lrange("score", 0, -1);
//        System.out.println(score);
        //一次型删除多个数据--易发生错误

//        jedisCluster.del("age","name");
        //当键所在槽的位置不在同一个空间之中，不可一次性删除多个键
        //依次删除--推荐
//        jedisCluster.set("age","20");
//        jedisCluster.del("name");
//        jedisCluster.del("age");
        //使用哈希标签将多个键放在同一个哈希槽
//        jedisCluster.set("{user}:name","xiaohu");
//        jedisCluster.set("{user}:age","26");
        //一次性删除name,age
        jedisCluster.del("{user}:name");
        jedisCluster.del("{user}:age");
    }
}
